package com.login.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.common.util.BaseAction;
import com.login.action.fo.LeaveMessageFO;
import com.login.service.ILeaveMessageServ;

public class LeaveMessageAction extends BaseAction {
	private static final long serialVersionUID = 1L;
	public static Logger log = Logger.getLogger(LeaveMessageAction.class);
	private LeaveMessageFO fo;
	private  int id;
	private String title;
	private String content;
	private String qq;
	private String email;
	private String userName;
	private String telphoneNum;

	private ILeaveMessageServ servMessage;
	private int page;
	private int rows;
	private int total;
	public String searchFinaList() {
		Map<String, Object> paraMap = new HashMap<String, Object>();

		int start = (page - 1) * rows;
		int end = page * rows;
		paraMap.put("start", start);
		paraMap.put("end", end);
		String result = servMessage.searchFinaList(paraMap);
		PrintWriter out =null;
			try {
				 out = response.getWriter();
				response.setCharacterEncoding("utf-8");
				out.write(result);

			} catch (IOException e) {
				log.error("search fina error", e);
			}
		//	return "success"; 不能这样返回  引起前台页面数据展现不出来		
			return null;
		}
	
	public String addSaveFina()
	{
		Map<String, Object> paraMap = new HashMap<String, Object>();
		paraMap.put("title", title);
		paraMap.put("qq", qq);
		paraMap.put("email", email);
		paraMap.put("content", content);
		paraMap.put("userName", userName);
		paraMap.put("telphoneNum", telphoneNum);
		servMessage.saveSysmenu(paraMap);
		return "success";
	}
	
	public static void main(String[] args) 
	{
		
		//System.out.print(dateToString("2011-01-02 01:00:00"));
	}

	  
	public String deleteByIds() throws IOException {
		try {
			String ids = request.getParameter( "ids");
			boolean isFlag =servMessage.deleteByIdString(ids);
			response.setContentType("text/html;charset=utf-8");
			if (isFlag)
				message = "删除成功";
			else
				message = "删除失败";
			StringBuffer sb = new StringBuffer("[");
			sb.append("{\"message\":\"" + message + "\"" + "}");
			sb.append("]");
			this.response.getWriter().print(sb.toString());
		} catch (Exception e) {
			log.error("delete menulist error", e);
		}
		return null;
	}
	public LeaveMessageFO getFo() {
		return fo;
	}
	public void setFo(LeaveMessageFO fo) {
		this.fo = fo;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getQq() {
		return qq;
	}
	public void setQq(String qq) {
		this.qq = qq;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getTelphoneNum() {
		return telphoneNum;
	}
	public void setTelphoneNum(String telphoneNum) {
		this.telphoneNum = telphoneNum;
	}
	public int getPage() {
		return page;
	}
	public void setPage(int page) {
		this.page = page;
	}
	public int getRows() {
		return rows;
	}
	public void setRows(int rows) {
		this.rows = rows;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public void setServMessage(ILeaveMessageServ servMessage) {
		this.servMessage = servMessage;
	}
	
	

}
